<div class="container">
    <div class="row">
        <table class="table table-stripped" border="1">
            <thead>
                <tr>
                    <th>#</th>
                    <th>Pertanyaan</th>
                    <?php for($i=1;$i<=$jumlah->jumlah_opsi;$i++){?>
                    <th>Opsi <?php echo $i; ?></th>
                    <?php } ?>
                    <th>kunci</th>
                    <th>Edit</th>
                </tr>
            </thead>
            <tbody>
                <?php
                function truncate($text){
                    if(strlen($text) >= 15){
                        $str = substr($text, 0, 15).' ...';
                    }else{
                        $str = $text;
                    }
                    return $str;
                }
                ?>
                <?php $i = 0; foreach($rows as $row){ $i++;?>
                <tr>
                    <td><?php echo $i; ?></td>
                    <td><?php echo truncate($row->soal); ?></td>
                        <?php
                        switch ($jumlah->jumlah_opsi) {
                            case 3:
                                echo "<td>".truncate($row->opsia)."</td>
                                    <td>".truncate($row->opsib)."</td>
                                    <td>".truncate($row->opsic)."</td>";
                                break;
                            case 4:
                                echo "<td>".truncate($row->opsia)."</td>
                                    <td>".truncate($row->opsib)."</td>
                                    <td>".truncate($row->opsic)."</td>
                                    <td>".truncate($row->opsid)."</td>";
                                break;
                            case 5:
                                echo "<td>".truncate($row->opsia)."</td>
                                    <td>".truncate($row->opsib)."</td>
                                    <td>".truncate($row->opsic)."</td>
                                    <td>".truncate($row->opsid)."</td>
                                    <td>".truncate($row->opsie)."</td>";
                                break;
                        }
                        ?>
                    <td><?php echo 'opsi '.truncate($row->kunci)?></td>
                    <td><?php echo anchor('guru/editdetailsoal/'.$row->id, 'Edit'); ?></td>
                </tr>
                <?php } ?>
            </tbody>
        </table>
    </div>
</div>